﻿@model IceTea.Domain.Models.Product 

@using (Ajax.BeginForm("EditBasicInfo", "Product", new AjaxOptions()
    {
        Url = Url.Action("EditBasicInfo", "Product"),
        UpdateTargetId = "editbasicinfo"
    }, new { @class="col-md-12"}))
{
<div class="modal-dialog">
    <div class="modal-content">

        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">@((Model == null || Model.Id <= 0)? "Create New Product" : "Edit Product" )</h4>
        </div>

        <div class="modal-body">
            <div class="control-group">@Html.ValidationSummary()</div>

            <div class="form-horizontal col-md-12" role="form">
                <!-- Project Name -->
                <div class="form-group">
                    @Html.LabelFor(p => p.Name, new { @class="control-label col-md-2"}) 
                    <div class="col-md-9">
                        @Html.TextBoxFor(p => p.Name, new{@class="form-control", @autofocus="autofocus"})
                    </div>
                    <div class="col-md-1"><span class="glyphicon glyphicon-asterisk"></span></div>
                </div>

                <!-- Project Description -->
                <div class="form-group">
                    @Html.LabelFor(p => p.Description, new { @class="control-label col-md-2"})
                    <div class="col-md-9">
                        @Html.TextAreaFor(p => p.Description, 5, 20, new{@class="form-control"})
                    </div>
                </div>

                <!-- Sprint duration -->
                <div class="form-group">
                    @Html.LabelFor(p => p.SprintDuration, new { @class="control-label col-md-2"})
                    <div class="col-md-9">
                        @Html.DropDownListFor(p => p.SprintDuration, 
                        new List<SelectListItem>(){
                            new SelectListItem(){ Text="One Week", Value="1"},
                            new SelectListItem(){ Text="Two Week", Value="2", Selected=true},
                            new SelectListItem(){ Text="Three Week", Value="3"},
                            new SelectListItem(){ Text="Four week", Value="4"},},
                            new{@class="form-control"})
                    </div>
                </div>

                <!-- Project vision -->
                <div class="form-group">
                    @Html.LabelFor(p => p.Vision, new{@class="control-label col-md-2"})
                    <div class="col-md-9">
                        @Html.TextAreaFor(p => p.Vision, 8, 20, new{@class="form-control"})
                    </div>
                </div>

                <div class="form-group">
                    @Html.HiddenFor(p => p.Id)
                </div>
            </div>
        </div>
    
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary">Save</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
    </div>

</div>
</div>
}

<script type="text/javascript">
    @if (ViewBag.Result == IceTea.Infrastructure.EditResult.Start)
    {
        @:$('#editbasicinfo').modal('show');
    }
    else if (ViewBag.Result == IceTea.Infrastructure.EditResult.Success)
    {
        @:$('#editbasicinfo').modal('hide');
        @:$('#btnrefresh').click();
    }
</script>